<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->


            <button class="btn btn-danger" id="refreshBtn">刷新缓存</button>

            <form class="form-horizontal" role="form">
                {foreach name="list" item="l"}
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> {$l['note']} </label>
                    <div class="col-sm-9">
                        {if condition="0 EQ $l['type']"}
                        <input type="text" id="form-field-1" class="col-xs-10 col-sm-5" value="{$l['config_value']}"/>
                        <button class="btn btn-sm btn-info save_btn" type="button" style="height: 28px;line-height: 15px;" data-id="{$l['id']}">
                            <i class="icon-ok bigger-110"></i>保存
                        </button>
                        {else/}
                        <textarea name="goods_info" id="fullText_{$l['id']}">{$l['config_value']}</textarea>
                        <button class="btn btn-sm btn-info save_btn" type="button" style="height: 28px;line-height: 15px;" data-id="{$l['id']}">
                            <i class="icon-ok bigger-110"></i>保存
                        </button>
                        {/if}
                    </div>
                </div>
                {/foreach}
            </form>


        </div><!-- /.col -->
    </div><!-- /.row -->
</div><!-- /.page-content -->

<script>
    $(".lm").addClass("active open");
    $(".lm .pz").addClass("active");


    $('.save_btn').click(function(){
        let id = $(this).attr('data-id');
        let config_value = $(this).prev().val();
        $.post("{:url('index/saveConfig')}", {id:id, config_value:config_value}, function(data){
            alert(data.message);
            window.location.reload();
        });
    });

</script>

<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<!--编辑器语言加载-->
<script type="text/javascript" src="__STATIC__/ueditor/lang/zh-cn/zh-cn.js"></script>

<link type="text/css" rel="stylesheet" href="__STATIC__/ueditor/third-party/video-js/video-js.css"/>
<script language="javascript" type="text/javascript" src="__STATIC__/ueditor/third-party/video-js/video.js"></script>

<!-- 实例化编辑器 -->
<script type="text/javascript">
    let config = {
        initialFrameWidth: "100%", //初化宽度
        initialFrameHeight: 200, //初化高度
        serverUrl: "{$server_url}",
        maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
        toolbars: [
            ['fullscreen', 'source', '|', 'undo', 'redo','|', 'bold', 'italic', 'underline', 'fontborder',
                'strikethrough', 'removeformat', 'formatmatch', 'autotypeset',
                'blockquote', 'pasteplain', '|', 'forecolor','backcolor', 'insertorderedlist',
                'insertunorderedlist', 'selectall', 'cleardoc', '|','rowspacingtop', 'rowspacingbottom',
                'lineheight', '|','customstyle', 'paragraph', 'fontfamily', 'fontsize','|','indent' , 'justifyleft', 'justifycenter','justifyright',
                'justifyjustify',  '|', 'link', 'unlink', 'horizontal']
        ]
    };
    let list = {$list2};
    $.each(list, function(k, v){
        let ue = UE.getEditor('fullText_'+v['id'],config);
    });

    $('#refreshBtn').click(function(){
         bootbox.confirm('是否刷新当前缓存', function(clickRes){
             if(clickRes){
                 $.post("{:url('Index/refreshCache')}", {}, function(data){
                     bootbox.alert(data.message, function(){
                        window.location.reload();
                     });
                 });
             }
         });
    });
</script>